package com.own.center;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.own.core.html.form.validateType;
import com.own.core.html.form.dropDown.DropDown;
import com.own.core.html.form.object.ObjectField;
import com.own.core.html.form.textArea.TextArea;
import com.own.core.html.form.textField.TextField;
import com.own.core.object.Dao;

@Entity
@Table(name = "cm_hole")
@NamedQueries({ @NamedQuery(name = "hole.listByCenter", query = "select h from Hole  h "
		+ " join h.center c " + " where c.id=:id ") })
public class Hole extends Dao {

	private long id;

	@TextField(required = true, linkable = "seats")
	private String name;

	// @TextField(number=true)
	// private long capcity;

	@TextField(number = true)
	private long row;

	@TextField(number = true)
	private long colume;

	@TextField
	private String seatPrefixName;

	// @DropDown
	private Center center;

	// @ObjectField
	private Set<Seat> seats;

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	// public long getCapcity() {
	// return capcity;
	// }

	// public void setCapcity(long capcity) {
	// this.capcity = capcity;
	// }

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "center_id", nullable = true)
	public Center getCenter() {
		return center;
	}

	public void setCenter(Center center) {
		this.center = center;
	}

	@OneToMany(mappedBy = "hole")
	@OrderBy("name")
	public Set<Seat> getSeats() {
		return seats;
	}

	public void setSeats(Set<Seat> seats) {
		this.seats = seats;
	}

	public long getRow() {
		return row;
	}

	public void setRow(long row) {
		this.row = row;
	}

	public long getColume() {
		return colume;
	}

	public void setColume(long colume) {
		this.colume = colume;
	}

	public String getSeatPrefixName() {
		return seatPrefixName;
	}

	public void setSeatPrefixName(String seatPrefixName) {
		this.seatPrefixName = seatPrefixName;
	}

}
